/* eslint-disable */
const {injectBabelPlugin} =require("react-app-rewired");
const rewireStyl = require('react-app-rewire-stylus-modules');
const rewireReactHotLoader = require('react-app-rewire-hot-loader')

module.exports = function override(config, env) {
  // 设置 source map
  if (env !== 'production') {
    config.devtool = 'inline-source-map';
   
  }

  //设置 压缩插件的属性 mangle
  for (const item of config.plugins) {
    if (item.options && item.options.mangle) {
      item.options.mangle = false;
    }
  }

  config = injectBabelPlugin(
    ['import',{libraryName:'antd',style:true}],
    config
  )

  config = injectBabelPlugin('transform-decorators-legacy',config)
  
  // theme

  config = rewireStyl(config, env);

  config = rewireReactHotLoader(config,env)

  config=require('react-app-rewire-postcss')(config, {
    options: { sourceMap: true }
  });

  return config;
};
